package com.aisa.tracker;

import java.util.Calendar;
import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.content.Intent;
import android.widget.TimePicker;
import android.widget.TextView;


public class Morning extends Activity {
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.morning);
			
			defaultTimes();
	}
	
	private TimePicker sleep;
	private TimePicker wake;
	
	public void defaultTimes() {
 
		sleep = (TimePicker) findViewById(R.id.sleep_picker);
		wake = (TimePicker) findViewById(R.id.wake_picker);

		sleep.setCurrentHour(23);
		sleep.setCurrentMinute(0);
		wake.setCurrentHour(8);
		wake.setCurrentMinute(0);

	}
	
	public void submit(View view) {
		int sleep_time;
		int wake_time;
		int sleep_length;
		TextView output;
		sleep_time = 60*sleep.getCurrentHour()+sleep.getCurrentMinute();
		wake_time = 60*wake.getCurrentHour()+wake.getCurrentMinute();
		if(sleep_time > wake_time) {
			sleep_length = wake_time + 1440 - sleep_time;
		} else {
			sleep_length = wake_time - sleep_time;
		}
		output = (TextView) findViewById(R.id.test_sleep);
		output.setText("You slept from "+sleep_time+" to "+wake_time+" - length of "+sleep_length);
	}

}